package Checkers; 

import java.io.File;
import javax.swing.JFrame;

public class runCheckers {

    /**
     * @param args
     */
    /**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event-dispatching thread.
     */
    private static boolean AIVSAI = true;
    
    private static checkersGUI screen;
    
    private static void createAndShowGUI() {
        //Create and set up the window.
        screen = new checkersGUI();
        JFrame frame = screen.getCheckersMainFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //Display the window.
        frame.pack();
        frame.setVisible(true);
    }
    
    /*private static void createAndShowWelcome(){
        WelcomeScreen screen = new WelcomeScreen();
        JFrame frame = screen.getWelcomeFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //Display the window.
        frame.pack();
        frame.setVisible(true);
    }*/
    
    public static void main(String[] args) throws ClassNotFoundException {
        System.out.println("-----------------------PROGRAM START------------------------");
        //Stratagem.connectDB("jdbc:mysql://localhost:3306/checkers", "cse282", "xxx");
        //Stratagem.testDB();
        
        int numArgs = args.length;
        if ( numArgs >= 1) {
            createAndShowGUI();
            screen.contactServer( args[0] );
        }
        else {
        javax.swing.SwingUtilities.invokeLater( new Runnable() {
            public void run() {
                //createAndShowWelcome();
                createAndShowGUI();
                if (AIVSAI) new Thread(screen).start();
            }
        });
        }
        //Stratagem.disconnectDB();
	}

}
